const CracoAntDesignPlugin = require('craco-antd')
// const WebpackBar = require('webpackbar')
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin')
const path = require('path')

const resolve = (dir) => path.resolve(__dirname, dir)

module.exports = {
  webpack: {
    alias: {
      //使用@替换src
      '@': resolve('src'),
    },
    plugins: [
      // 查看打包的进度
      new SimpleProgressWebpackPlugin(),
      // 查看启动进度
      // new WebpackBar(),
    ],
  },
  plugins: [
    {
      plugin: CracoAntDesignPlugin,
      options: {
        customizeTheme: {},
      },
    },
  ],
  // 支持装饰器
  babel: {
    plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]],
  },
  // 配置跨域
  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:3001',
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/api',
        },
      },
    },
  },
}
